#include "lcd_task.h"
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

#include "lcd.h"
#include "pic.h"

#include "stdio.h"
#include "DJI_motor.h"
#include "Claw.h"
#include "tim.h"
#include "mainc.h"

extern float pitch, yaw, roll;
uint16_t adc_val[2];
float vbus;
extern uint16_t dis;
extern int32_t angl;
extern uint16_t step;
void LCD_TASK(void *argument)
{
    HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
    HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adc_val, 2); // 读取ADC按键键�??
//    LCD_Init();                                        // LCD初始�??????????????
//    LCD_Fill(0, 0, LCD_W, LCD_H, BLACK);
//    HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
    for (;;)
    {

//        vbus = (adc_val[0] * 3.3f / 65535) * 11.09f;
//        LCD_ShowIntNum(20, 0, adc_val[1], 5, WHITE, BLACK, 32);
//        // LCD_ShowIntNum(140, 0, adc_val[0], 5, WHITE, BLACK, 32);
//        LCD_ShowFloatNum(140, 0, vbus, 3, 2, WHITE, BLACK, 32);
//        LCD_ShowFloatNum(20, 32, yaw, 2, 2, RED, BLACK, 32);
//        LCD_ShowFloatNum(20, 64, pitch, 2, 2, RED, BLACK, 32);
//        LCD_ShowFloatNum(20, 96, roll, 2, 2, RED, BLACK, 32);
//        LCD_ShowFloatNum(140, 32,CMode , 2, 2, RED, BLACK, 32);
        // LCD_ShowIntNum(140, 90, step, 5, BLUE, BLACK, 32);
        if(adc_val[1]<1000)
        {
            osDelay(100);
            if(adc_val[1]<1000)
            {
                if(CMode==0)
                {
                    CMode=1;
                }
//                else
//                {
//                    CMode=0;
//                }
            }
        }
        vTaskDelay(10);
    }
}